<?php
namespace dingtalk;

use dingtalk\util\Http;

class CallBack
{

    /**
     * 注册事件回调接口
     * @param $accessToken
     * @param $call
     * @return mixed
     */
    public static function registerCallBack($accessToken,$call)
    {
        $response = Http::post("/call_back/register_call_back", ["access_token" => $accessToken],json_encode($call));
        return obj2array($response);
    }

    /**
     * 查询事件回调接口
     * @param $accessToken
     * @return mixed
     */
    public static function getCallBack($accessToken)
    {
        $response = Http::get("/call_back/get_call_back", ["access_token" => $accessToken]);
        return obj2array($response);
    }

    /**
     * 更新事件回调接口
     * @param $accessToken
     * @param $call
     * @return mixed
     */
    public static function updateCallBack($accessToken,$call)
    {
        $response = Http::post("/call_back/update_call_back", ["access_token" => $accessToken],json_encode($call));
        return obj2array($response);
    }

    /**
     * 删除事件回调接口
     * @param $accessToken
     * @return mixed
     */
    public static function deleteCallBack($accessToken)
    {
        $response = Http::get("/call_back/delete_call_back", ["access_token" => $accessToken]);
        return obj2array($response);
    }
}